package cate.game.role.x;

import cate.game.db.MongoCache;
import cate.game.role.Role;
import cate.game.role.RolePart;
import org.springframework.data.mongodb.repository.MongoRepository;

import java.util.Optional;

public abstract class RolePartWorker<P extends RolePart> {

    protected Role role;

    public void setup(Role role) {
        this.role = role;
    }

    protected MongoCache mongoCache() {
        return this.role.getGame().facilities.getMongoCache();
    }

    public abstract Optional<P> findById(MongoRepository<P, String> repo, String uid);

    public abstract void save(MongoRepository<P, String> repo, P part);

}
